package com.chaopei.goods_mng_impl.controller;

import com.chaopei.goods_mng_api.api.ProductFacade;
import com.chaopei.goods_mng_api.entity.Product;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Corday 天涯
 * @Date 2022/5/5 17:25
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @Resource
    private ProductFacade productFacade;

    //    1.提供接口1,实现伪RPC(远程过程调用)调用
    // http://localhost:8082/product/getProducts
    @RequestMapping("/getProducts")
    //@CrossOrigin,如果前端app需要直接调用,则要设置跨域
    public List<Product> getProducts() {
        return productFacade.queryProducts();
    }

    //    提供接口2
    // http://localhost:8082/product/ps
    @RequestMapping("/ps")
    public List<Product> getProducts(String nameCode) {
        return productFacade.queryProductsByNameOrCode(nameCode);
    }

}
